<template>
  <a-card :bordered="false" width="100%">
    <!-- 查询区域 -->
    <div class="table-page-search-wrapper">
      <a-form layout="inline" @keyup.enter.native="searchQuery">
        <a-row :gutter="24">
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <a-form-item label="任务名称">
              <a-input placeholder="请输入任务名称" v-model="queryParam.taskName"></a-input>
            </a-form-item>
          </a-col>
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <a-form-item label="任务开始时间">
              <j-date :show-time="true" date-format="YYYY-MM-DD HH:mm:ss" placeholder="请选择任务开始时间"
                v-model="queryParam.taskStartDate"></j-date>
            </a-form-item>
          </a-col>
          <template v-if="toggleSearchStatus">
            <a-col :xl="6" :lg="7" :md="8" :sm="24">
              <a-form-item label="任务持续时间">
                <!-- <j-date
                  :show-time="true"
                  date-format="YYYY-MM-DD HH:mm:ss"
                  placeholder="请选择任务持续时间"
                  v-model="queryParam.taskDuration"
                ></j-date>-->
                <a-input suffix="分钟" v-model="model.taskDuration" placeholder="请输入任务持续时间"></a-input>
              </a-form-item>
            </a-col>
            <a-col :xl="6" :lg="7" :md="8" :sm="24">
              <a-form-item label="状态">
                <a-input placeholder="请输入状态" v-model="queryParam.state"></a-input>
              </a-form-item>
            </a-col>
          </template>
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <span style="float: left; overflow: hidden" class="table-page-search-submitButtons">
              <a-button type="primary" @click="searchQuery" icon="search">查询</a-button>
              <a-button type="primary" @click="searchReset" icon="reload" style="margin-left: 8px">重置</a-button>
              <!-- <a @click="handleToggleSearch" style="margin-left: 8px">
                {{ toggleSearchStatus ? '收起' : '展开' }}
                <a-icon :type="toggleSearchStatus ? 'up' : 'down'" />
              </a>-->
            </span>
          </a-col>
        </a-row>
      </a-form>
    </div>
    <!-- 查询区域-END -->

    <!-- 操作按钮区域 -->
    <div class="table-operator">
      <a-button @click="handleAdd" type="primary" icon="plus">新增</a-button>
      <!-- <a-button type="primary" icon="download" @click="handleExportXls('作战需求')">导出</a-button>
      <a-upload
        name="file"
        :showUploadList="false"
        :multiple="false"
        :headers="tokenHeader"
        :action="importExcelUrl"
        @change="handleImportExcel"
      >
        <a-button type="primary" icon="import">导入</a-button>
      </a-upload>-->
      <!-- 高级查询区域 -->
      <!-- <j-super-query :fieldList="superFieldList" ref="superQueryModal"
        @handleSuperQuery="handleSuperQuery"></j-super-query> -->
      <a-dropdown v-if="selectedRowKeys.length > 0">
        <a-menu slot="overlay">
          <a-menu-item key="1" @click="batchDel">
            <a-icon type="delete" />删除
          </a-menu-item>
        </a-menu>
        <a-button style="margin-left: 8px">
          批量操作
          <a-icon type="down" />
        </a-button>
      </a-dropdown>
    </div>

    <!-- table区域-begin -->
    <div style="width:100%;min-height:calc(100vh - 300px)">
      <div class="ant-alert ant-alert-info" style="margin-bottom: 16px">
        <i class="anticon anticon-info-circle ant-alert-icon"></i> 已选择
        <a style="font-weight: 600">{{ selectedRowKeys.length }}</a>项
        <a style="margin-left: 24px" @click="onClearSelected">清空</a>
      </div>
      <div>
        <a-table class="j-table-force-nowrap" ref="table" size="middle" bordered rowKey="id" :columns="columns"
          :scroll="{ x: true }" :dataSource="dataSource" :pagination="ipagination" :loading="loading"
          :rowSelection="{ selectedRowKeys: selectedRowKeys, onChange: onSelectChange }" @change="handleTableChange">
          <template slot="IndicatorLight" slot-scope="text,record">
            <div v-if="isToday(new Date(record.taskStartDate))"
              style="display: flex;justify-content: center;align-items: center;">
              <a-tooltip placement="top">
                <template slot="title">
                  <span> 通联业务处理器星指链路模式控制</span>
                </template>
                <span
                  :class="String(record.modeControlTcFlag) == 'true' ? 'onStyle' : String(record.modeControlTcFlag) == 'false' ? 'offStyle' : 'noStyle'">
                </span>
              </a-tooltip>
              <a-tooltip placement="top">
                <template slot="title">
                  <span> Ka接收机频率</span>
                </template>
                <span
                  :class="String(record.upCfpTcFlag) == 'true' ? 'onStyle' : String(record.upCfpTcFlag) == 'false' ? 'offStyle' : 'noStyle'">
                </span>
              </a-tooltip>
              <a-tooltip placement="top">
                <template slot="title">
                  <span>Ka上变频器频率</span>
                </template>
                <span
                  :class="String(record.downCfpTcFlag) == 'true' ? 'onStyle' : String(record.downCfpTcFlag) == 'false' ? 'offStyle' : 'noStyle'">
                </span>
              </a-tooltip>
              <a-tooltip placement="top">
                <template slot="title">
                  <span> 通联业务处理器L星弹链路模式控制</span>
                </template>
                <span
                  :class="String(record.missileDownRateAndFrequencyTcFlag) == 'true' ? 'onStyle' : String(record.missileDownRateAndFrequencyTcFlag) == 'false' ? 'offStyle' : 'noStyle'"></span>
              </a-tooltip>
              <a-tooltip placement="top">
                <template slot="title">
                  <span> L可控接收机本振</span>
                </template>
                <span
                  :class="String(record.localOscillatorTcFlag) == 'true' ? 'onStyle' : String(record.localOscillatorTcFlag) == 'false' ? 'offStyle' : 'noStyle'"></span>
              </a-tooltip>
              <a-tooltip placement="top">
                <template slot="title">
                  <span>可控接收机滤波器控制指令</span>
                </template>
                <span
                  :class="String(record.intermediateFrequencyTcFlag) == 'true' ? 'onStyle' : String(record.intermediateFrequencyTcFlag) == 'false' ? 'offStyle' : 'noStyle'"></span>
              </a-tooltip>
              <a-tooltip placement="top">
                <template slot="title">
                  <span>星弹上行链路数字滤波器控制指令</span>
                </template>
                <span
                  :class="String(record.digitalFilterTcFlag) == 'true' ? 'onStyle' : String(record.digitalFilterTcFlag) == 'false' ? 'offStyle' : 'noStyle'"></span>
              </a-tooltip>
              <a-tooltip placement="top">
                <template slot="title">
                  <span>通联业务处理器接口及加解密模式控制</span>
                </template>
                <span
                  :class="String(record.encryptionTcFlag) == 'true' ? 'onStyle' : String(record.encryptionTcFlag) == 'false' ? 'offStyle' : 'noStyle'"></span>
              </a-tooltip>
            </div>

            <span v-else>——</span>

          </template>
          <template slot="htmlSlot" slot-scope="text">
            <div v-html="text"></div>
          </template>

          <template slot="imgSlot" slot-scope="text, record">
            <span v-if="!text" style="font-size: 12px; font-style: italic">无图片</span>
            <img v-else :src="getImgView(text)" :preview="record.id" height="25px" alt
              style="max-width: 80px; font-size: 12px; font-style: italic" />
          </template>

          <template slot="fileSlot" slot-scope="text">
            <span v-if="!text" style="font-size: 12px; font-style: italic">无文件</span>
            <a-button v-else :ghost="true" type="primary" icon="download" size="small"
              @click="downloadFile(text)">下载</a-button>
          </template>

          <span slot="action" slot-scope="text, record">
            <!-- <a @click="resend(record)">重发</a> -->

            <!-- <a-divider type="vertical" /> -->
            <!-- <a @click="soltConfig(record)" >卫星配置</a>

            <a-divider type="vertical" />
             <a @click="pointConfig(record)">频点分配</a>

            <a-divider type="vertical" />

              <a @click="queryAndSend(record)" >查发指令</a> -->
            <!--  <a-popconfirm  title="确定删除吗?" overlayClassName="poperLayTable"  @confirm="() => handleDelete(record.id)">
              <a>删除</a>
            </a-popconfirm> -->

            <a @click="handleEdit(record)" :disabled="disabledEdit(record)">编辑</a>
            <!-- <a @click="handleEdit(record)">编辑</a> -->
            <a-divider type="vertical" />
            <a-dropdown>
              <a class="ant-dropdown-link">
                更多
                <a-icon type="down" />
              </a>
              <a-menu slot="overlay">
                <!-- <a-menu-item>
                  <a @click="soltConfig(record)">时隙分配</a>
                </a-menu-item> -->
                <!-- <a-menu-item>
                  <a @click="handleEdit(record)" :disabled="disabledEdit(record)">编辑</a>
                </a-menu-item> -->

                <a-menu-item>
                  <a @click="handleDetail(record)">详情</a>
                </a-menu-item>
                <a-menu-item>
                  <a-popconfirm title="确定删除吗?" overlayClassName="poperLayTable"
                    @confirm="() => handleDelete(record.id)">
                    <a>删除</a>
                  </a-popconfirm>
                </a-menu-item>
              </a-menu>
            </a-dropdown>
          </span>
        </a-table>
        <a-drawer title="卫星配置" placement="right" width="100%" :visible="visible" :get-container="false"
          :wrap-style="{ position: 'absolute' }" @close="onClose">
          <resource-car-allocation ref="resourceCarAllocation" />
        </a-drawer>
        <a-drawer title="频点分配" placement="right" width="100%" :visible="visiblePoint" :get-container="false"
          :wrap-style="{ position: 'absolute' }" @close="onClosePoint">
          <resource-ball-allocation ref="resourceBallAllocation" />
        </a-drawer>
      </div>
    </div>
    <!-- <a-modal width="45%" v-model="visibleManualConfig" title="手动配置" @ok="handleOk">
      <template slot="footer">

        <a-popconfirm
          title="确定发送配置?"
          @confirm="handleOk"
        >
        <a-button key="submit" type="primary" >
          发送
        </a-button>
        </a-popconfirm>

      </template>
      <div class="infoBox" >
      <p>
        {{ manualConfigInfo }}
      </p>

    </div>

    </a-modal>-->
    <a-modal width="75%" v-model="visibleManualConfig" title="查发指令">
      <template slot="footer">
        <a-button key="back" @click="handleCancel">
          取消
        </a-button>
      </template>
      <h2>请按顺序发送指令</h2>

      <div class="infoBox" v-for='item in instructionsList' :key='item.id'>
        <div class='leftBox'>
          <div class='leftBox_header'>
            <p>指令名称：{{ item.instructionName }}</p>
            <p>发送顺序：{{ item.order }}</p>
          </div>
          <p>{{ item.manualConfigInfo }}</p>
          <div class='leftBox_footer'>
            <a-popconfirm title="确定发送配置?" @confirm="handleOk1(item)">
              <a-button type="primary">
                发送
              </a-button>
            </a-popconfirm>
          </div>

        </div>
        <div class='rightBox'>
          <!-- <a-card title="对应遥测" :bordered="false" style="width: 300px"> -->
          <a-descriptions title="对应遥测" :column=1>
            <a-descriptions-item :key='is.paramName' :label="is.paramName" v-for='is in item.telemetryList'>
              {{ is.telemetryValue }}
            </a-descriptions-item>
          </a-descriptions>
          <!-- </a-card> -->
          <!--           <p>指令执行结果：{{filterResultsOfEnforcement(item.resultsOfEnforcement)}}</p>-->
        </div>

      </div>
    </a-modal>
    <nmc-fight-demand-modal ref="modalForm" @ok="modalFormOk"></nmc-fight-demand-modal>
  </a-card>
</template>

<script>
import '@/assets/less/TableExpand.less'
import { mixinDevice } from '@/utils/mixin'
import { JeecgListMixin } from '@/mixins/JeecgListMixin'
import NmcFightDemandModal from './modules/NmcFightDemandModal'
import { filterMultiDictText } from '@/components/dict/JDictSelectUtil'
import ResourceCarAllocation from './resourceCarAllocation.vue'
import ResourceBallAllocation from './resourceBallAllocation.vue'
import { httpAction, getAction } from '@/api/manage'
import { mapGetters } from 'vuex'

import moment from 'moment'
const wrapStyles = {
  overflow: 'hidden',
  position: 'relative',
  padding: '24px',
  border: '1px solid #e9e9e9',
};
export default {
  name: 'NmcFightDemandList',
  mixins: [JeecgListMixin, mixinDevice],
  components: {
    NmcFightDemandModal,
    ResourceCarAllocation, ResourceBallAllocation
  },

  computed: {
    ...mapGetters(['websocketMsg']),
    websocketMsg() {
      return this.$store.state.user.websocketMsg
    },
  },
  watch: {
    websocketMsg: {
      handler(val) {
        // 需要进行的操作
        let msg = JSON.parse(val)

        if (msg.cmd == 'SC_TELEMETRY_CLOSED_LOOP') {
          if (this.visibleManualConfig) {
            getAction(this.url.genManualConfigVos, { fightDemandId: this.fightDemandId }).then(res => {
              if (res.success) {
                // this.visibleManualConfig=true
                this.instructionsList = res.result.sort((a, b) => a.order - b.order)
              } else {
                this.$message.error(res.message)
              }
            })
          }
        }
        console.log(val, 'val----websocket推送的全局数据')

      },
    },
  },
  data() {
    return {
      wrapStyles,
      manualConfigInfo: '',
      paramsdata: {},
      description: '作战需求管理页面',
      visibleManualConfig: false,
      instructionsList:
        [
          {
            id: 1, instructionName: '星地对时指令',
            order: '0',
            resultsOfEnforcement: '0001',
            manualConfigInfo: "1ACFFC1D03AC3C3A0530053F040000000000000000000000000000000000000000000000000000000000000000001ACFFC1D601300047F0000000000000000000000000000000000000000000000000000000000000000003FFF103FC001000815054109020202C21F082000000000000B008ADD5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A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5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5AEEC9AA",
            telemetryList: [
              {
                paramsName: 'VX015', telemetryValue: '0F25'
              }
            ]
          },
          {
            id: 2, instructionName: '星地对时指令111',
            order: '2',
            resultsOfEnforcement: '0002',
            manualConfigInfo: "1ACFFC1D03AC3C3A0530053F040000000000000000000000000000000000000000000000000000000000000000001ACFFC1D601300047F0000000000000000000000000000000000000000000000000000000000000000003FFF103FC001000815054109020202C21F082000000000000B008ADD5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A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5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5AEEC9AA",
            telemetryList: [
              {
                paramsName: 'VX015', telemetryValue: '0F25'
              }
            ]
          }
        ],
      // 表头
      columns: [
        // {
        //   title: '#',
        //   dataIndex: '',
        //   key: 'rowIndex',
        //   width: 60,
        //   align: 'center',
        //   customRender: function (t, r, index) {
        //     return parseInt(index) + 1
        //   },
        // },
        {
          title: '任务名称',
          align: 'center',
          width: 120,
          dataIndex: 'taskName',
        },

        {
          title: '任务开始时间',
          align: 'center',
          width: 180,
          dataIndex: 'taskStartDate',
        },
        {
          title: '任务结束时间',
          align: 'center',
          width: 180,
          dataIndex: 'taskEndDate',
        },
        // {
        //   title: '任务持续时间',
        //   align: 'center',
        //   dataIndex: 'taskDuration',
        //   customRender: function (t, r, index) {
        //     return t ? t + '分钟' : '/'
        //   },
        // },
        // {
        //   title: '指挥车入网认证码',
        //   align: 'center',
        //   width: 160,
        //   dataIndex: 'ncvNetAccessAuthCode',
        // },
        // {
        //   title: '任务状态',
        //   align: 'center',
        //   dataIndex: 'status',
        // },
        // {
        //   title: '指示灯',
        //   align: 'center',
        //   width: 160,
        //   scopedSlots: { customRender: 'IndicatorLight' },
        // },
        // {
        //   title: '指挥车数量',
        //   align: 'center',
        //   dataIndex: 'ncvNum',
        //   width: 120,
        // },
        {
          title: '通信方式',
          align: 'center',
          // width: 120,
          dataIndex: 'communicationType',
          customRender: function (t, r, index) {
            return t == '00' ? "明态" : t == '11' ? "密态" : "/"
          },
        },
        // {
        //   title: '导弹总数',
        //   align: 'center',
        //   dataIndex: 'missileTotal',
        // },
        {
          title: '星指下行',
          children: [
            {
              title: '通信频点',
              align: 'center',
              width: 100,
              dataIndex: 'satelliteDownCvCf',
              customRender: function (t, r, index) {
                return t + 'G'
              },
            },
            {
              title: '通信速率',
              align: 'center',
              width: 100,
              dataIndex: 'satelliteDownCvCr',
            },
            {
              title: '跳频模式',
              align: 'center',
              width: 100,
              dataIndex: 'satelliteDownCvCfType_dictText',
            },
          ],
        },
        {
          title: '星指上行',
          children: [
            {
              title: '通信频点',
              align: 'center',
              width: 100,
              dataIndex: 'satelliteUpCvCf',
              customRender: function (t, r, index) {
                return t + 'G'
              },
            },
            {
              title: '通信速率',
              align: 'center',
              width: 100,
              dataIndex: 'satelliteUpCvCr',
            },
            {
              title: '跳频模式',
              align: 'center',
              width: 100,
              dataIndex: 'satelliteUpCvCfType_dictText',
            },
          ],
        },

        // {
        //   title: '状态',
        //   align: 'center',
        //   dataIndex: 'state',
        // },

        {
          // title: '操作',
          // dataIndex: 'action',
          // // align: 'center',
          // fixed: 'right',
          // width: 220,
          // scopedSlots: { customRender: 'action' },

          title: '操作',
          key: 'operation',
          // fixed: 'right',
          // zIndex: 2,
          width: 200,
          scopedSlots: { customRender: 'action' },
        },
      ],
      visible: false,
      visiblePoint: false,
      url: {
        genManualConfigFrame: "/fightDemand/nmcFightDemand/genManualConfigFrame",
        manualConfig: "/fightDemand/nmcFightDemand/manualConfig",
        list: '/fightDemand/nmcFightDemand/list',
        delete: '/fightDemand/nmcFightDemand/delete',
        deleteBatch: '/fightDemand/nmcFightDemand/deleteBatch',
        exportXlsUrl: '/fightDemand/nmcFightDemand/exportXls',
        importExcelUrl: 'fightDemand/nmcFightDemand/importExcel',
        genManualConfigVos: "/fightDemand/nmcFightDemand/genManualConfigVos",
        manualConfig: '/fightDemand/nmcFightDemand/manualConfig'
      },
      dictOptions: {},
      superFieldList: [],
      fightDemandId: ''
    }
  },
  created() {
    this.getSuperFieldList()
  },
  mounted() {

    //this.queryParam.taskStartDate=moment().format('YYYY-MM-DD HH:mm:ss')
    // console.log();
  },
  computed: {
    importExcelUrl: function () {
      return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`
    },
  },
  methods: {
    filterResultsOfEnforcement(val) {
      if (val == 'SUCCESS' || val == 'SKIP') {
        return '成功'
      } else if (val == 'TELEMETRY_CLOSED_LOOP') {
        return '设置中'
      } else if (val == 'TIMEOUT') {
        return '已超时'
      } else {
        return ''
      }
    },
    queryAndSend(record) {
      this.fightDemandId = record.id
      getAction(this.url.genManualConfigVos, { fightDemandId: record.id }).then(res => {
        if (res.success) {
          this.visibleManualConfig = true
          this.instructionsList = res.result.sort((a, b) => a.order - b.order)
        } else {
          this.$message.error(res.message)
        }
      })

    },
    handleCancel() {

      this.visibleManualConfig = false
    },
    handleOk1(item) {
      let paramsdata = {
        fightDemandId: this.fightDemandId,
        type: item.manualConfigType
      }
      httpAction(this.url.manualConfig, new URLSearchParams(Object.entries(paramsdata)), 'post').then(res => {
        // httpAction(this.url.manualConfig,paramsdata,'post').then(res=>{
        if (res.success) {
          this.$message.success(res.message)
          // this.visibleManualConfig=false
          getAction(this.url.genManualConfigVos, { fightDemandId: this.fightDemandId }).then(res => {
            if (res.success) {
              // this.visibleManualConfig=true
              this.instructionsList = res.result.sort((a, b) => a.order - b.order)
            } else {
              this.$message.error(res.message)
            }
          })
        } else {
          // this.visibleManualConfig=false
          this.$message.error(res.message)
        }
      })
    },
    handleOk() {
      httpAction(this.url.manualConfig, new URLSearchParams(Object.entries(this.paramsdata)), 'post').then(res => {
        if (res.success) {
          this.$message.success(res.message)
          this.visibleManualConfig = false
          this.loadData()
        } else {
          this.visibleManualConfig = false
          this.$message.error(res.message)
        }
      })
    },
    handleFlag(val, record, flag) {
      // if(flag)return
      if (record)
        this.paramsdata = {
          fightDemandId: this.fightDemandId,
          type: val
        }

      //指示等点击事件
      httpAction(this.url.genManualConfigFrame, new URLSearchParams(Object.entries(this.paramsdata)), 'post').then(res => {
        if (res.success) {
          if (res.result != '') {
            this.visibleManualConfig = true
            this.manualConfigInfo = res.result
          } else {
            this.loadData()
          }
        } else {
          this.$message.error(res.message)
        }
      })
      return
      if (val == 'dfConfigFlag') {
        //数字滤波器设置标记

      } else if (val == 'downCfpConfigFlag') {
        //星指下行通信频点设置标记

      } else if (val == 'ifConfigFlag') {
        //中频滤波器设置标记

      } else if (val == 'loConfigFlag') {
        //本振设置标记

      } else if (val == 'modeControlConfigFlag') {
        //通联业务处理器链路模式控制设置标记

      } else if (val == 'resourceLockFlag') {
        //资源锁定标记

      } else if (val == 'smDownRateAndFpConfigFlag') {
        //星弹下行速率控制成功标记

      } else if (val == 'upCfpConfigFlag') {
        //星指上行通信频点设置标记

      }
    },
    isToday(date) {
      // 判断一个时间是不是今天范围内的时间
      const start = new Date();
      const end = new Date();

      // 将时间设置为当天的凌晨零点
      start.setHours(0, 0, 0, 0);

      // 将时间设置为当天的23:59:59
      end.setHours(23, 59, 59, 999);

      // 判断date是否在[start, end]区间内
      return date >= start && date <= end;
    },
    getPopupContainer(trigger) {
      return trigger.parentElement;
    },
    disabledEdit(record) {
      // console.log(new Date(record.taskStartDate).getTime(), 'taskStartDate')
      // console.log(new Date().getTime(), '现在时间')
      let recordTime = new Date(record.taskStartDate).getTime()
      let nowTime = new Date().getTime()
      if (recordTime < nowTime || record.resourceLockFlag == 'LOCK') { return true } else { return false }
    },
    pointConfig(record) {
      this.visiblePoint = true;
      this.$refs.resourceBallAllocation.init(record)
      // this.$refs.resourceBallAllocation.getcarsource()
      // this.$refs.resourceBallAllocation.getValueByCode()
    },
    soltConfig(record) {
      this.visible = true;
      // console.log(record, 'record')
      // this.$refs.resourceCarAllocation.fightDemandId = record.id
      // this.$refs.resourceCarAllocation.disabledEdit = this.disabledEdit(record)
      this.$refs.resourceCarAllocation.init(record, this.disabledEdit(record))
      this.$refs.resourceCarAllocation.getcarsource()
      this.$refs.resourceCarAllocation.getValueByCode()
      //做弹窗/做跳转
      // this.$router.push({
      //   path: '/taskManagement/resourceCarAllocation', query: { id: '1' }
      // })
    },
    onClose() {
      this.visible = false;
      this.loadData()
      this.$refs.resourceCarAllocation.emptyData()
    },
    onClosePoint() {
      this.visiblePoint = false;
      this.loadData()
      this.$refs.resourceBallAllocation.emptyData()
    },
    configCar(record) {
      console.log(this.$refs.createDataModal.visible)
      this.$refs.createDataModal.showModal(record)
    },
    initDictConfig() { },
    getSuperFieldList() {
      let fieldList = []
      fieldList.push({ type: 'string', value: 'taskName', text: '任务名称', dictCode: '' })
      fieldList.push({ type: 'datetime', value: 'taskStartDate', text: '任务开始时间' })
      fieldList.push({ type: 'datetime', value: 'taskEndDate', text: '任务持续时间' })
      fieldList.push({ type: 'string', value: 'ncvNetAccessAuthCode', text: '指挥车入网认证码', dictCode: '' })
      fieldList.push({ type: 'int', value: 'ncvNum', text: '指挥车数量', dictCode: '' })
      fieldList.push({ type: 'string', value: 'satelliteDownCvCf', text: '星指下行通信频点', dictCode: '' })
      fieldList.push({ type: 'string', value: 'satelliteDownCvCr', text: '星指下行通信速率', dictCode: '' })
      fieldList.push({
        type: 'int',
        value: 'satelliteDownCvCfType',
        text: '星指下行跳频模式',
        dictCode: 'satellite_down_cv_cf_type',
      })
      fieldList.push({ type: 'string', value: 'satelliteUpCvCf', text: '星指上行通信频点', dictCode: '' })
      fieldList.push({ type: 'string', value: 'satelliteUpCvCr', text: '星指上行通信速率', dictCode: '' })
      fieldList.push({
        type: 'int',
        value: 'satelliteUpCvCfType',
        text: '星指上行跳频模式',
        dictCode: 'satellite_up_cv_cf_type',
      })
      fieldList.push({ type: 'int', value: 'state', text: '状态', dictCode: 'nmc_fight_demand_state' })
      this.superFieldList = fieldList
    },
  },
}
</script>

<style lang='less' scoped>
@import '~@assets/less/common.less';

a[disabled] {
  color: #908989;
}

.infoBox {
  border: 1px solid #26fbf3;
  margin: 8px;
  padding: 10px;
  display: flex;
  color: #fff;
  justify-content: space-between;

  .leftBox {
    border-right: 1px solid;
    padding: 15px;
    width: 70%;

    .leftBox_header {
      display: flex;
      justify-content: space-between;

    }

    .leftBox_footer {
      width: 100%;
      display: flex;
      justify-content: flex-end;
    }

  }

  .rightBox {

    width: 28%;
  }
}

.onStyle,
.offStyle,
.noStyle {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: inline-block;
  margin-right: 5px;
}

.onStyle {
  background: rgb(56, 241, 56);
}

.offStyle {
  background: red;
}

.noStyle {
  border: 1px solid;
  background: transparent;
}
</style>
